if (!global.ShadowMamba) {
global.ShadowMamba = {};
        }
var sm = global.ShadowMamba;

function sm_after_item_equipped(e) {
var item = e.item;
var unit = e.unit;
var flags = item.ScriptFlags;
if (flags.get("remove_flying")) {
if (unit.Flying) {
unit.Flying=false;
say(unit.GetName()+" is no longer flying.");
}
}
if (flags.get("grant_flight_on_equip")) {
if (!unitWasOriginallyFlying(unit)) {
/*var rF = false;
var effects = unit.Effects;
for (var i = 0; i < effects.length; i++) {
if (
//(effects[i].ScriptFlags.get("remove_flying")) == false) {*/
//} else {
unit.Flying = true;
say(unit.GetName() + " is now flying.");
//}
//}
}
}
if (flags.get("aditional_description")) {
var descriptor = flags.get("aditional_description");
if (!(unit.FriendlyType.indexOf(descriptor) > -1)) {
// indexOf looks through a string and returns the index (or position) of the sought for string, or -1 if it's not there
// so if the indexOf isn't -1 here, we know that unit's FriendlyType contains the word we're looking for and should handle it somehow
unit.FriendlyType = descriptor + " " + unit.FriendlyType;
shared.ShareUnitUpdate(unit);
}
}
}

function sm_after_item_unequipped(u) {
var item = u.item;
var unit = u.unit;
var flags = item.ScriptFlags;
if (flags.get("remove_flying")) {
if (unitWasOriginallyFlying(unit)) {
unit.Flying=true;
say(unit.GetName()+" is now flying.");
}
}
if (flags.get("grant_flight_on_equip")) {
if (!unitWasOriginallyFlying(unit)) {
if (unit.Flying == true) {
unit.Flying=false;
say(unit.GetName()+" is no longer flying.");
}
}
}
if (flags.get("aditional_description")) {
var descriptor = flags.get("aditional_description");
unit.FriendlyType = (unit.FriendlyType).replace(descriptor, "");
unit.FriendlyType = (unit.FriendlyType).trim();
shared.ShareUnitUpdate(unit);
}
}

/*
function sm_randomEquipment(r) {
var unit = r.unit;
var flags = unit.ScriptFlags;
if (flags.get("random_equipment")) {
var slot = 
var eSlots = slot.split(",");
for (var i = 0; i < eSlots.length; i++) {
var slots = eSlots[i];


*/
